//
//  PhotoBrowserView.m
//  etionUI
//
//  Created by WangJian on 14-2-14.
//  Copyright (c) 2014年 GuangZhouXuanWu. All rights reserved.
//

#import "PhotoBrowserView.h"
#import "ImageAnimatedShowView.h"

@implementation CPhotoBrowserLayout

@end

@interface CPhotoBrowserView() <CPhotoBrowserViewCellDelegate>


@end

@implementation CPhotoBrowserView

- (id)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self.imageBrowserView registerClass:[CPhotoBrowserViewCell class] forCellWithReuseIdentifier:@"photoCell"];
    }
    return self;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CPhotoBrowserViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"photoCell" forIndexPath:indexPath];
    CPhotoBrowserViewCellInfo *info = [self.delegate imageBrowserView:self cellInfoAtIndex:indexPath.item];
    [cell updateWithCellInfo:info];
    cell.remarkOffset = self.showBtns ? 55 : 0;
    cell.delegate = self;
    return cell;
}

- (void)tapGestureResponse:(UITapGestureRecognizer *)tapgesture
{
    [super tapGestureResponse:tapgesture];
    CPhotoBrowserViewCell *cell = (CPhotoBrowserViewCell *)[self cellAtIndex:self.curImageIndex];
    [UIView animateWithDuration:.25 animations:^{
        cell.remarkOffset = self.showBtns ? 55 : 0;
    }];
}

- (void)photoBrowserViewCellRemarkChange:(CPhotoBrowserViewCell *)cell
{
    [self.delegate photoBrowserView:self cellAtIndex:[self.imageBrowserView indexPathForCell:cell].item remarkChange:cell.remark];
}

- (void)photoBrowserViewCellStartEditRemark:(CPhotoBrowserViewCell *)cell
{
    self.imageBrowserView.scrollEnabled = NO;
    [self hideButtonItemsAnimated:YES complete:^(BOOL finished) {
        
    }];
}

- (void)photoBrowserViewCellEndEditRemark:(CPhotoBrowserViewCell *)cell
{
    self.imageBrowserView.scrollEnabled = YES;
    [self showButtonItemsAnimated:YES complete:^(BOOL finished) {
        
    }];
}

@end
